﻿<cfsilent>
	<cfscript>
		
		event.setArg("pageTitle", "考场座次表");
		
		examId = event.getArg("EXID");
		clsroomId = event.getArg("CRID");
		
		
		/* 加载考试任务 */
		sql = "SELECT 
					t_examtask.task_exid, 
					t_course.course_name, 
					t_course.course_code,
					t_course.course_credit, 
					t_institute.institute_name, 
					t_term.academic_year, 
					t_term.academic_term 
				FROM 
					t_examtask 
					INNER JOIN t_course ON t_course.cid = t_examtask.cid 
					INNER JOIN t_institute ON t_institute.institute_id = t_course.institute_id 
					INNER JOIN t_term ON t_term.term_id = t_examtask.term_id 
				WHERE 
					t_examtask.task_exid = :taskExid ";
					
		queryObj = new query( datasource=application.dnsSlave );
		
		queryObj.addParam( name="taskExid", value=examId, cfsqltype="cf_sql_char" );
		
		rs_examTask = queryObj.execute( sql=sql ).getResult();
		
		/*考场名称*/
		sql = "SELECT 
					classroom 
				FROM 
					t_classroom 
				WHERE 
					cr_id = :classroomId";

		queryObj = new query( datasource=application.dnsSlave );
		
		queryObj.addParam( name="classroomId", value=clsroomId, cfsqltype="cf_sql_char" );
		
		rs_classRoom = queryObj.execute( sql=sql ).getResult();
	
		/* 考场名单 */
		sql = "SELECT 
					t_student_exam.sitidx, 
					t_student.stu_id, 
					t_student.stu_name 
				FROM 
					t_student_exam 
					INNER JOIN t_student ON t_student.stu_id = t_student_exam.stu_id 
				WHERE 
					t_student_exam.task_exid = :examId 
					AND 
					t_student_exam.cr_id = :clsroomId 
				ORDER BY 
					t_student_exam.sitidx " ;
		
		queryObj = new query( datasource=application.dnsSlave );
		
		queryObj.addParam( name="examId", value=examId, cfsqltype="cf_sql_char" );
		queryObj.addParam( name="clsroomId", value=clsroomId, cfsqltype="cf_sql_char" );
		
		rs_student = queryObj.execute( sql=sql ).getResult();
			
		/* 默认显示行数及高度 */
		rowPerSlide = 8;
		rowPerPage = rowPerSlide * 7;
		
		/* Chrome Print Fix */
		if ( findNoCase( "Chrome", CGI.HTTP_USER_AGENT, 1) ) {
			rowPerSlide = 8;
			rowPerPage = rowPerSlide * 6;
		}

		
		if ( rs_student.recordCount ) {
			
			/* 计算打印页数 */
			if ( rs_student.recordCount mod rowPerPage ) {
				totlePageCount = int(rs_student.recordCount/rowPerPage) + 1;
			}
			else {
				totlePageCount = int(rs_student.recordCount/rowPerPage);
			}
			
			pageRowBegin = 1;
			pageRowEnd = min(rowPerPage, rs_student.recordCount);
			
			tagCode = "ZCB-" & rs_examTask.task_exid;

		}
		
	</cfscript>
</cfsilent>

<cfloop from="1" to="#totlePageCount#" index="currentPage">
	
	<cfif currentPage GT 1><div class="page_break"></div></cfif>
	<div class="UIprintableTitle"><cfoutput>#rs_examTask.course_name#</cfoutput> <cfoutput>#rs_classRoom.classroom#</cfoutput> 考场座次表</div>
	
	<table width="98%" border="0" cellpadding="1" cellspacing="0">
		<tr>
			<td>课程号 <cfoutput>#rs_examTask.course_code#</cfoutput></td>
			<td>课程 <cfoutput>#rs_examTask.course_name#</cfoutput></td>
			<td>学分 <cfoutput>#numberFormat(rs_examTask.course_credit, "_.__")#</cfoutput></td>
			<td align="right">任课单位 <cfoutput>#rs_examTask.institute_name#</cfoutput></td>
		</tr>
		<tr>
			<td>学期 <cfoutput>#rs_examTask.academic_year#</cfoutput>-<cfoutput>#rs_examTask.academic_term#</cfoutput></td>
			<td>考场 <cfoutput>#rs_classRoom.classroom#</cfoutput></td>
			<td>考场人数 <cfoutput>#rs_student.recordCount#</cfoutput></td>
			<td align="right">第<cfoutput>#currentPage#</cfoutput>页 共<cfoutput>#totlePageCount#</cfoutput>页</td>
		</tr>
	</table>
	
	<div class="clear2px"></div>
	
	<table width="100%" cellpadding="0" cellspacing="0">
		
		<cfloop index="row" from="#pageRowBegin#" to="#pageRowEnd#">
			
			<cfif row mod rowPerSlide eq 1><tr></cfif>
						
			<td align="center" width="<cfoutput>#int(100/rowPerSlide)#</cfoutput>%">
				<div class="clear5px"></div>
				<div><img width="75" height="100" align="middle" src="<cfoutput>#getContextRoot()#</cfoutput>/acadmicManager/student/profile/<cfoutput>#rs_student["stu_id"][row]#</cfoutput>.jpg" /></div>
				<em><cfoutput>#rs_student["stu_id"][row]#</cfoutput><br/><cfoutput>#rs_student["sitidx"][row]#</cfoutput> <cfoutput>#rs_student["stu_name"][row]#</cfoutput></em>
			</td>
			
			<!--- 补空格 --->
			<cfif row eq pageRowEnd and row mod rowPerSlide gt 0>
				<cfloop from="1" to="#(rowPerSlide - (row mod rowPerSlide))#" index="space">
					<td width="<cfoutput>#int(100/rowPerSlide)#</cfoutput>%">&nbsp;<!-- <cfoutput>#space#</cfoutput> --></td>
				</cfloop>
			</cfif>
			
			<cfif row mod rowPerSlide eq 0></tr></cfif>
		
		</cfloop>
		
		
	</table>
	
	<div class="clear2px"></div>
	
	<table width="100%" cellpadding="0" cellspacing="0">
		<tr>
			<td width="150">打印时间 <cfoutput>#dateFormat(now(), "YYYY年MM月DD日")#</cfoutput></td>
			<td width="100">第 <cfoutput>#currentPage#</cfoutput> 页, 共 <cfoutput>#totlePageCount#</cfoutput> 页</td>
			<td align="right"><img src="<cfoutput>#getContextRoot()#</cfoutput>/barcode/Print/<cfoutput>#tagCode#</cfoutput>,<cfoutput>#currentPage#</cfoutput>.png" height="43"/></td>
		</tr>
	</table>
	
	<cfset pageRowBegin = pageRowBegin + rowPerPage />
	<cfset pageRowEnd = pageRowEnd + rowPerPage />
	<cfif pageRowEnd gt rs_student.recordCount>
		<cfset pageRowEnd = rs_student.recordCount />
	</cfif>
	
</cfloop>

